import  sys
result={}

for line in sys.stdin:
    line=line.strip()
    m,f=line.split(' ')
    if m in result:
        result[m].append(f)
    else:
        result[m]=[f]

for m,f in result.items():
    print(m,f)